# -*- coding:utf-8 -*-
# @time:2020-9-5 14:39
# POWERD BY:ECHO
# from autoFrame.common import config
#
# print(config.config["mailtxt"])

# from appium import webdriver
#
#
# conf = {
#                       "platformName": "Android",
#                       "platformVersion": "5.1.1",
#                       "deviceName": "127.0.0.1:62001",
#                       "appPackage": "com.tencent.mm",
#                       "appActivity": ".ui.LauncherUI",
#                       "noReset": True,
#                       "unicodeKeyboard": True,
#                       "resetKeyboard": True,
#                       "automationName": "UiAutomator1"
#                     }
#
#
# driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub",conf)
# driver.implicitly_wait(10)
# driver.find_element_by_xpath("").send_keys("")
# driver.find_element_by_xpath("").click()
# driver.find_element_by_xpath("").text

# print(str("0x97"))
# import os
#
# from selenium import webdriver
#
# option = webdriver.ChromeOptions()
# userfile = os.environ["USERPROFILE"] #获取用户文件路径
# #chrome://version查看个人资料路径
# option.add_argument(r"--user-data-dir=%s\AppData\Local\Google\Chrome\User"%userfile)
# exepath = "./lib/conf/chromedriver.exe"
#
# driver = webdriver.Chrome(options=option,executable_path=exepath)
#
# # exepath = "./lib/conf/geckodriver.exe"
# # opt = webdriver.FirefoxOptions()
# # #about:support
# # opt.profile = r'%s\AppData\Roaming\Mozilla\Firefox\Profiles\pza6n3te.default-release' % os.environ["USERPROFILE"]
# # driver = webdriver.Firefox(executable_path=exepath,options=opt)
#
#
# driver.get("https://h.cn/")
# import time
#
# from appium import webdriver
# caps = {
#                       "platformName": "Android",
#                       "platformVersion": "10",
#                       "deviceName": "6HJ4C20110006671",
#                       "appPackage": "com.evergrande.bao.consumer",
#                       "appActivity": ".splash.SplashActivity",
#                       "noReset": True,
#                       "unicodeKeyboard": True,
#                       "resetKeyboard": True,
#                       "automationName": "UiAutomator1"
#                     }
# driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)
# driver.implicitly_wait(10)
# time.sleep(5)

# params = "ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd=ip&fenlei=256&oq=split&rsv_pq=e0a3144000079f03&rsv_t=762bergCBDbZbLMxBqP%2BCAttFFmDn7ZA74qSlWvmCayLMg6Rs8gSR8cMdok&rqlang=cn&rsv_enter=1&rsv_dl=tb&rsv_btype=t&inputT=659&rsv_sug3=7&rsv_sug1=6&rsv_sug7=100&rsv_sug2=0&rsv_sug4=659"
# parm = {}
# p1 = params.split("&")
# print(p1)
# print(type(p1))
#
# for keyvalue in p1:
#     index = keyvalue.find("=")
#     # print(str(keyvalue) + "+++" + str(index))
#     if index >= 0:
#         key = keyvalue[0:index]
#         value = keyvalue[index+1:]
#         parm[key] = value
#     else:
#         parm[key] = ""
#
# print(parm)
# import jsonpath
# jsonres = {"ResultCode":"0","ResultNum":"1"}
# print(type(jsonres))
# print(jsonpath.jsonpath(jsonres,"$.ResultCode"))


# def fun1():
#     print("echo is a good man")
#
# def outer():
#     print("***************")
#     fun1()
#
# outer()

# def fun1():
#     print("echo is a good man")
#
# def outer(func):
#     def inner():
#         print("******************")
#         func()
#     return inner
#
# f = outer(fun1)
# f()

# def say(age):
#     print("echo is %d years old" %age)
#
# def outer(func):
#     def inner(age):
#         if age < 0:
#             age = 0
#         func(age)
#     return inner
#
# say = outer(say)
# print(say)
import hashlib
import json
import time
import unittest

import study_unittest

import jsonpath
import requests


s = requests.session()
#默认请求头
s.headers["Content-Type"] = "application/json,charset=utf-8"
s.headers["terminalType"] = "android"
s.headers["loginSelection"] = "1"
s.headers["User-Agent"] = "okhttp/4.7.2"


#登录
# res = s.post("https://broker-sit-api.fcb.com.cn/appapi/broker/uucas/v1/loginUucas",
#              json={"phone":"18617099614","os_type":"Android","pwd":"d797b2011f0dcf584c786c2a33dacb44"})
# print(res .text)
#把登录返回信息存到请求头


# res = s.post("https://broker-sit-api.fcb.com.cn/appapi/broker/uucas/v1/getVerificationCode",json={'phone': '15811258830', 'type': 2})
# print(res.text)
# print(type(res.text))
# res = json.loads(res.text)
# print(jsonpath.jsonpath(res,"$.code"))
# res = s.post("https://broker-sit-api.fcb.com.cn/appapi/broker/uucas/v1/loginByCode",json={"code":"111111","jpushId":"100d855909cdf03380c","lbsCityCode":"110100","phone":"15811258830","siteCityCode":"110100","app_uuid":"ea5e2e25f6024562","app_version":"1.4.0","hardware_version":"HUAWEI","os_type":"Android","os_version":"android_29"})

# res = s.post("https://broker-sit-api.fcb.com.cn/appapi/broker/uucas/v1/loginUucas",json={"phone":"15811258830","os_type":"Android","pwd":"3649016ae1305e3132683409341c96d8"})
# print(res.text)
#
# print(jsonpath.jsonpath(res.text,"$.code"))
# p = "{'code': '1112222', 'jpushId': '100d855909cdf03380c', 'lbsCityCode': '110100', 'phone': '15811258830', 'siteCityCode': '110100', 'app_uuid': 'ea5e2e25f6024562', 'app_version': '1.4.0', 'hardware_version': 'HUAWEI', 'os_type': 'Android', 'os_version': 'android_29'}"
# p1 = '{"code":"111111","jpushId":"100d855909cdf03380c","lbsCityCode":"110100","phone":"15811258830","siteCityCode":"110100","app_uuid":"ea5e2e25f6024562","app_version":"1.4.0","hardware_version":"HUAWEI","os_type":"Android","os_version":"android_29"}'
# p2 = json.loads(p1)
# #
# res = s.post("https://broker-sit-api.fcb.com.cn/appapi/broker/uucas/v1/getVerificationCode",json={"phone":"15811258830","type":2})
# print(res.text)
# res = s.post("https://broker-sit-api.fcb.com.cn/appapi/broker/uucas/v1/loginByCode",json=p2)
# print(res)
# restext = res.text
# print(restext)
# restext = json.loads(restext)
# print(restext)
#
# access_token = jsonpath.jsonpath(restext,"$..access_token")[0]
# print(access_token)
#
# broker_id = jsonpath.jsonpath(restext,"$..broker_id")[0]
# print(broker_id)
#
# union_id = jsonpath.jsonpath(restext,"$..union_id")[0]
# print(union_id)
#
# s.headers["Authorization"] = access_token
# s.headers["unionId"] = union_id
# s.headers["brokerId"] = broker_id
#
# res = s.post("https://broker-sit-api.fcb.com.cn/appapi/broker/member/v1/getProfile",json={})
# print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
# print(res.content.decode("utf8"))

# res = s.post("https://broker-sit-api.fcb.com.cn/backapi/prod/labelInfo/v1/hotLabel",json={"current":1,"size":8})
# print(res.text)
#
# res = s.post("https://broker-sit-api.fcb.com.cn/backapi/prod/prod/v2/queryAppDistributeRuleByParam",json={"prodId":"7911396775702210400"})
# print(res.text)
# import time
# start_time = time.time()
# time.sleep(0.5)
# end_time = time.time()
#
# cost_time = end_time - start_time
# print(cost_time*1000)
# relations = {"currentCityCode":"440100"}
# params = '{aaaaa{currentCityCode}bbbbb}'
#
# for key in relations.keys():
#     print(key)
#     params = params.replace("{" + key + "}", str(relations[key]))
#
# print(params)

# p = {'code': '000000', 'message': None, 'data': {'records': [{'id': '1336868480221208577', 'liveTopic': '1210验证恒大宝', 'liveTopic1': '1', 'liveSection': None, 'buildingId': None, 'title': None, 'anchorName': '1', 'studioName': None, 'studioStatus': 1, 'liveUrl': 'http://mudu.tv/watch/6299711', 'startTime': '2020-12-10 00:00:00', 'endTime': '2021-01-31 00:00:00', 'livePlatform': None, 'auditInformation': None, 'liveStatus': 2, 'liveImages': ['https://fcb-hft-oss.fcb.com.cn/image/LINK/de6bc4b5e7315e50289f4c5b51983cff?Expires=1765249191&OSSAccessKeyId=LTAIgYXaMjqB4CgE&Signature=RC2vTA4exQRgvmaQd2zvzZF907Q%3D'], 'liveImage': 'https://fcb-hft-oss.fcb.com.cn/image/LINK/de6bc4b5e7315e50289f4c5b51983cff?Expires=1765249191&OSSAccessKeyId=LTAIgYXaMjqB4CgE&Signature=RC2vTA4exQRgvmaQd2zvzZF907Q%3D', 'createUser': 'atest\n丁强柱', 'createTime': '2020-12-10 11:00:58', 'updateUser': 'HD20081213\n刘华', 'updateTime': '2020-12-15 14:59:45', 'deleteFlag': 0, 'sort': None, 'buildingCity': '0', 'cityName': '全国', 'liveBackgroundImages': ['https://fcb-hft-oss.fcb.com.cn/image/LINK/ef3a5820f03e6e0d61f7330c09c785f6?Expires=1765249197&OSSAccessKeyId=LTAIgYXaMjqB4CgE&Signature=JYAy2nxXKb%2BunN5U%2FgBKvDafebg%3D'], 'liveBackgroundImage': 'https://fcb-hft-oss.fcb.com.cn/image/LINK/ef3a5820f03e6e0d61f7330c09c785f6?Expires=1765249197&OSSAccessKeyId=LTAIgYXaMjqB4CgE&Signature=JYAy2nxXKb%2BunN5U%2FgBKvDafebg%3D', 'clickSum': 56, 'isSubscribe': None, 'liveMode': 1}, {'id': '1332863910595809281', 'liveTopic': '全国置顶-地产1', 'liveTopic1': '11', 'liveSection': None, 'buildingId': None, 'title': None, 'anchorName': '11', 'studioName': None, 'studioStatus': 1, 'liveUrl': 'http://mudu.tv/watch/6299711', 'startTime': '2020-11-29 00:00:00', 'endTime': '2020-12-29 00:00:00', 'livePlatform': None, 'auditInformation': None, 'liveStatus': 2, 'liveImages': ['https://fcb-hft-oss.fcb.com.cn/image/LINK/b36f89ed9094a70dfad54d3f11f5433b?Expires=1764293872&OSSAccessKeyId=LTAIgYXaMjqB4CgE&Signature=8751NpQSEt6pZSHpUyKeGXiYtA8%3D'], 'liveImage': 'https://fcb-hft-oss.fcb.com.cn/image/LINK/b36f89ed9094a70dfad54d3f11f5433b?Expires=1764293872&OSSAccessKeyId=LTAIgYXaMjqB4CgE&Signature=8751NpQSEt6pZSHpUyKeGXiYtA8%3D', 'createUser': 'atest\n丁强柱', 'createTime': '2020-11-29 09:48:14', 'updateUser': 'atest\n丁强柱', 'updateTime': '2020-12-08 19:58:56', 'deleteFlag': 0, 'sort': None, 'buildingCity': '0', 'cityName': '全国', 'liveBackgroundImages': ['https://fcb-hft-oss.fcb.com.cn/image/LINK/1458edaa8a0b6c35dc3be64d86400951?Expires=1764293877&OSSAccessKeyId=LTAIgYXaMjqB4CgE&Signature=TvcsSLQpzcXGvat7GIVjxDDKVUM%3D'], 'liveBackgroundImage': 'https://fcb-hft-oss.fcb.com.cn/image/LINK/1458edaa8a0b6c35dc3be64d86400951?Expires=1764293877&OSSAccessKeyId=LTAIgYXaMjqB4CgE&Signature=TvcsSLQpzcXGvat7GIVjxDDKVUM%3D', 'clickSum': 4, 'isSubscribe': None, 'liveMode': 1}], 'total': 2, 'size': 10, 'current': 1, 'pages': 1}}
# # p1 = jsonpath.jsonpath(p,"$..id")[0]
# # print(p1)
# value = str(jsonpath.jsonpath(p,"$..id")[0])
# print(value)
# params = '{"id":"{liveid}"}'
# relations = {"liveid":value}
# for key in relations.keys():
#     print(key)
#     params = params.replace("{" + key + "}",value)
# print(params)

# res = s.post("http://10.101.40.139:9200/hdb-prod-build-v3/_search",json={"query" : { "match" : { "_id" : "1695693385039705989" }}})
# print(s.headers)
# print(res.text)
# import this
# import antigravity

# list_0 = [1,2,3,4,5]
# list_1 = []
# while list_0:
#     list_1.append(list_0.pop())
# print(list_0)
# print(list_1)

# res = s.post("https://broker-sit-api.fcb.com.cn/buildingInfo/v1/buildStatus",json={
# 	"buildingId": 6023182183388269486,
# 	"orderType": 0,
# 	"roomGuid": ""
# })
# # print(res.text)
# s.headers["Content-Type"] = "application/x-www-form-urlencoded"
# res = s.post("https://broker-sit-api.fcb.com.cn/baseInfo/v1/getProvPcMapperDto")
# print(res)

# s = requests.session()
# s.headers["content-type"] = 'application/json; charset=utf-8'
# s.headers['user-agent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'
# s.headers["terminalType"] = "android"
# res = s.post("https://broker-sit-api.fcb.com.cn/appapi/broker/uucas/v1/loginUucas",json={"phone":"18617099614","os_type":"Android","pwd":"d797b2011f0dcf584c786c2a33dacb44"})
#
# Authorization = jsonpath.jsonpath(res.json(),"$..access_token")[0]
#
# unionId = jsonpath.jsonpath(res.json(),"$..union_id")[0]
# brokerId = jsonpath.jsonpath(res.json(),"$..broker_id")[0]
#
# p = {
#         "Authorization":Authorization,
#         "brokerId":brokerId,
#         "unionId":unionId,
# }
# s.headers.update(p)
#
#
# p = {"unionId":"unionId","accessToken":"Authorization"}
#
# res = s.post("https://broker-sit-api.fcb.com.cn/appapi/broker/member/v1/refreshToken",json=p)
# print(res.text)
#
# res = s.post("https://broker-sit-api.fcb.com.cn/appapi/broker/personal/collection/v1/getCollectionStatus",
#              json={"relationId":"6023182183388269486"})
# print(res.text)






